﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;
using ViCode_LeVi.Controls.Reports;
using DevExpress.XtraTreeList;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.Utils;
using ViCode_LeVi.Data;
using ViCode_LeVi.Configs;
using System.Collections.Specialized;
using ViCode_LeVi.Controls.Logs;
using ViCode_LeVi.Langs;

namespace ViCode_LeVi.Controls.ControlsWin
{


    public partial class DVContents : UserControl//, IfcDetailViewEx
    {
        protected TabIDType2 m_eType;
        private XtraReport2 m_oContentsReport;
        private WBTB_Button m_oCreateButton;

        public DVContents()
        {
            this.InitializeComponent();
            this.m_oSelectionTreeList.ToolTipController = ToolTipps.getController();
            this.m_oVersionCombo.ToolTipController = ToolTipps.getController();
            this.m_oVersionCombo.Visible = false;
            SetColor();
        }

        public DVContents(TabIDType2 eType)
        {
            this.InitializeComponent();
            this.m_oSelectionTreeList.ToolTipController = ToolTipps.getController();
            this.m_oVersionCombo.ToolTipController = ToolTipps.getController();
            this._FillTree();
            this.m_eType = eType;
            SetColor();
        }

        private void SetColor()
        {
            var brF = Assergs.Windows.ListViewPallet.Foreground;
            var brB = Assergs.Windows.ListViewPallet.BodyBackground;
            var brHL = Assergs.Windows.ListViewPallet.ButtonLightBackground2;
            if (brB != null)
            {
                this.BackColor =
                this.m_oSelectionTreeList.Appearance.Empty.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(brB.R)))), ((int)(((byte)(brB.G)))), ((int)(((byte)(brB.B)))));
            }
            if (brF != null)
            {
                this.ForeColor =
                this.m_oSelectionTreeList.Appearance.SelectedRow.ForeColor =
                this.m_oSelectionTreeList.Appearance.Row.ForeColor =
                this.m_oSelectionTreeList.Appearance.Empty.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(brF.R)))), ((int)(((byte)(brF.G)))), ((int)(((byte)(brF.B)))));
            }
            if (brHL != null)
            {
                m_oSelectionTreeList.Appearance.FocusedCell.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(brHL.R)))), ((int)(((byte)(brHL.G)))), ((int)(((byte)(brHL.B)))));
                m_oSelectionTreeList.Appearance.FocusedCell.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(brF.R)))), ((int)(((byte)(brF.G)))), ((int)(((byte)(brF.B)))));
                m_oSelectionTreeList.Appearance.FocusedRow.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(brHL.R)))), ((int)(((byte)(brHL.G)))), ((int)(((byte)(brHL.B)))));
                m_oSelectionTreeList.Appearance.FocusedRow.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(brF.R)))), ((int)(((byte)(brF.G)))), ((int)(((byte)(brF.B)))));

            }

            var btnBG = Assergs.Windows.ButtonPallet.NormalBackGroundBrush2;
            if (btnBG != null)
                m_oCreateButton.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(btnBG.R)))), ((int)(((byte)(btnBG.G)))), ((int)(((byte)(btnBG.B)))));

        }
        public void ClearAllNode()
        {
            this.m_oSelectionTreeList.ClearNodes();
        }
        protected TreeListNode _AddNode(string sNodeTitle, string sDescription, ContentSelectionType2 eContentID, TreeListNode oParentNode)
        {
            TreeListNode node = this.m_oSelectionTreeList.AppendNode(new object[] { sNodeTitle, sDescription, CheckState.Unchecked, eContentID }, oParentNode);
            node.StateImageIndex = 0;
            return node;
        }

        private void _ChangeCheckState(TreeListNode oNode)
        {
            CheckState state = oNode.CheckState;
            state = ((state == CheckState.Indeterminate) || (state == CheckState.Unchecked)) ? CheckState.Checked : CheckState.Unchecked;
            this.m_oSelectionTreeList.BeginUpdate();
            oNode.CheckState = state;
            oNode.StateImageIndex = (state == CheckState.Checked) ? 1 : 0;
            this.m_oSelectionTreeList.EndUpdate();
            //TreeListHelper.CheckParentsAndChilds(oNode);
        }

        public void _FillTree()
        {
            this.m_oSelectionTreeList.BeginUnboundLoad();
            ClearAllNode();
            this.m_oStep123Node = this._AddNode(RootData.Intance.Report_BusinessStrategy, "Section 1: Business Model , Business Environment , Business strategy", ContentSelectionType2.NOTHING, null);
            this.m_oStatusNode = this._AddNode(RootData.Intance.Report_SucessFactor, "Section 2: Potentially Portfolio", ContentSelectionType2.NOTHING, null);
            this.m_oActionsNode = this._AddNode(RootData.Intance.Report_MEASURE, "Section 3: Measures", ContentSelectionType2.NOTHING, null);
            this.m_oBankNode = this._AddNode(ControlTextInfoInData.Intance.UI_Comment, "Section 4: " + ControlTextInfoInData.Intance.UI_Comment, ContentSelectionType2.NOTHING, null);
            this.m_oAppendixNode = this._AddNode(RootData.Intance.Report_SucessFactor, "Section 5: " + RootData.Intance.Report_SucessFactor, ContentSelectionType2.NOTHING, null);
            this.m_oAppendixNodeEF = this._AddNode(RootData.Intance.Report_SucessFactor/*RootData.Intance.Report_SucessFactor*/, "Details " + RootData.Intance.Report_SucessFactor, ContentSelectionType2.NOTHING, this.m_oAppendixNode);
            this.m_oAppendixNodeQQS = this._AddNode("Weighting", "Detail of the Assessment", ContentSelectionType2.NOTHING, this.m_oAppendixNode);
            this.m_oNode_Image = this._AddNode(RootData.Intance.Report_Conclusion_Image, RootData.Intance.Report_Conclusion_Image, ContentSelectionType2.NOTHING, null);
            this.m_oNode_Finances = this._AddNode(RootData.Intance.Report_Finance, RootData.Intance.Report_Finance, ContentSelectionType2.NOTHING, null);
            this.m_oNode_Marketing= this._AddNode(RootData.Intance.Report_Marketing, RootData.Intance.Report_Marketing, ContentSelectionType2.NOTHING, null);
            this._AddNode(RootData.Intance.Report_BusinessModel /*"Business Model "*/, "Presentation des Business Model s", ContentSelectionType2.STEP1_CONTENTS, this.m_oStep123Node);
            this._AddNode(RootData.Intance.Report_BusinessModel_Comment /*"Comment Business Environment "*/, "Comment and Weighting", ContentSelectionType2.STEP1_BANK_COMMENTS, this.m_oStep123Node);
            this._AddNode(RootData.Intance.Report_BussinessEnvironment/*"Business Environment "*/, "Presentation of Business Environment", ContentSelectionType2.STEP2_CONTENTS, this.m_oStep123Node);
            this._AddNode(RootData.Intance.Report_BussinessEnvironment_Comment/*"Comment Business Environment "*/, "Comment and Weighting", ContentSelectionType2.NOTHING | ContentSelectionType2.STEP2_BANK_COMMENTS, this.m_oStep123Node);
            this._AddNode(RootData.Intance.Report_BusinessStrategy/*"Business strategy"*/, "Presentation der Business strategy", ContentSelectionType2.NOTHING | ContentSelectionType2.STEP3_CONTENTS, this.m_oStep123Node);
            this._AddNode(RootData.Intance.Report_BusinessStrategy_Comment/*"Comment Business strategy"*/, "Comment and Weighting", ContentSelectionType2.NOTHING | ContentSelectionType2.STEP3_BANK_COMMENTS, this.m_oStep123Node);
            this._AddNode(RootData.Intance.Report_EVALUATION, RootData.Intance.Report_EVALUATION + " with interpretation", ContentSelectionType2.NOTHING | ContentSelectionType2.STATUS_POT_PORTFOLIO, this.m_oStatusNode);
            this._AddNode(RootData.Intance.Report_SucessFactor_Comment/*"Comment Success Factors"*/, "Comment and Weighting", ContentSelectionType2.NOTHING | ContentSelectionType2.STEP6_BANK_COMMENTS, this.m_oStatusNode);
            this._AddNode(RootData.Intance.Report_MEASURE + " overview", "Description of planned Measures and Investments", ContentSelectionType2.NOTHING | ContentSelectionType2.ACTIONS_LIST, this.m_oActionsNode);
            this._AddNode(RootData.Intance.Report_MEASURE_Comment, "Comment and Weighting", ContentSelectionType2.STEP7_BANK_COMMENTS, this.m_oActionsNode);
            this._AddNode(RootData.Intance.Conclution_Summary_TabHeader_UIText, "Comment and Weight of Steps overview", ContentSelectionType2.BANK_COMMENTS_OVERVIEW, this.m_oBankNode);
            this._AddNode(RootData.Intance.Report_Conclusion_Comment/*"Comment Statements"*/, "Commentation and Weighting for the entire Report", ContentSelectionType2.STEP8_BANK_COMMENTS, this.m_oBankNode);
            this._AddNode("Definition " + RootData.Intance.Report_SucessFactor, "Definition of " + RootData.Intance.Report_SucessFactor + " in Survey", ContentSelectionType2.APP_FACTOR_DEFINITIONS, this.m_oAppendixNodeEF);
            this._AddNode("Weighting-Diagram", "Weighting-Diagram with interpretation", ContentSelectionType2.APP_IMPORTANCE_DIAGRAM, this.m_oAppendixNodeEF);
            this._AddNode(RootData.Intance.Report_SucessFactor + " with weighting", "Table all " + RootData.Intance.Report_SucessFactor + " with weighting (3 Periods)", ContentSelectionType2.APP_IMPORTANCE_TIMELINE, this.m_oAppendixNodeEF);
            this._AddNode(RootData.Intance.Report_SucessFactor_Weighting /*"Justification Weighting"*/, "Justification with weighting in running time Periode", ContentSelectionType2.APP_JSTFNS_IMPORTANCE, this.m_oAppendixNodeEF);
            this._AddNode(RootData.Intance.Report_SucessFactor_Weighting_Comment/*"Comment Weighting"*/, ControlTextInfoInData.Intance.UI_Comment + " " + RootData.Intance.Report_SucessFactor_Weighting/*"Comment and Weighting"*/, ContentSelectionType2.STEP4_BANK_COMMENTS, this.m_oAppendixNodeEF);
            this._AddNode("Diagram (HC, SC, RC)", "Three bar graphics (HC, SC, RC) with interpretation", ContentSelectionType2.APP_QQS_BARCHARTS, this.m_oAppendixNodeQQS);
            this._AddNode("Overview assessment in time series", "Table all " + RootData.Intance.Report_SucessFactor + " with weighting (3 Periods)", ContentSelectionType2.APP_QQS_TIMELINE, this.m_oAppendixNodeQQS);
            this._AddNode(RootData.Intance.Report_SucessFactor_Weighting/*"Justification Weighting"*/, "Justification the Weighting in running from current period", ContentSelectionType2.APP_JSTFNS_QQS, this.m_oAppendixNodeQQS);
            this._AddNode(RootData.Intance.Report_SucessFactor_Weighting_Comment/*"Comment Weighting"*/, ControlTextInfoInData.Intance.UI_Comment + " " + RootData.Intance.Report_SucessFactor_Weighting/*"Comment and Weighting"*/, ContentSelectionType2.STEP5_BANK_COMMENTS, this.m_oAppendixNodeQQS);
            this._AddNode(RootData.Intance.Report_Conclusion_Image, RootData.Intance.Report_Conclusion_Image, ContentSelectionType2.IMAGE, this.m_oNode_Image);
            this._AddNode(RootData.Intance.Report_Finance_BalancedScoreCards, RootData.Intance.Report_Finance_BalancedScoreCards, ContentSelectionType2.FINANCES_BALANCES, this.m_oNode_Finances);
            this._AddNode(RootData.Intance.Report_Finance_InvestmentCalculation, RootData.Intance.Report_Finance_InvestmentCalculation, ContentSelectionType2.FINANCES_INVESTMENT, this.m_oNode_Finances);
            this._AddNode(RootData.Intance.Report_Finance_PriceCalculation, RootData.Intance.Report_Finance_PriceCalculation, ContentSelectionType2.FINANCES_PRICE, this.m_oNode_Finances);
            this._AddNode(RootData.Intance.Report_Finance_TradeCalculation, RootData.Intance.Report_Finance_TradeCalculation, ContentSelectionType2.FINANCES_TRADE, this.m_oNode_Finances);

            this._AddNode(RootData.Intance.Report_Finance_InvestmentPlan, RootData.Intance.Report_Finance_InvestmentPlan, ContentSelectionType2.FINANCES_INVESTMENTPLAN, this.m_oNode_Finances);
            this._AddNode(RootData.Intance.Report_Finance_LiquidityPlan, RootData.Intance.Report_Finance_LiquidityPlan, ContentSelectionType2.FINANCES_LIQUIDITY, this.m_oNode_Finances);
            this._AddNode(RootData.Intance.Report_Finance_Profit, RootData.Intance.Report_Finance_Profit, ContentSelectionType2.FINANCES_PROFIT, this.m_oNode_Finances);
            this._AddNode(RootData.Intance.Report_Finance_SheetStatement, RootData.Intance.Report_Finance_SheetStatement, ContentSelectionType2.FINANCES_Sheet_Statement, this.m_oNode_Finances);
            
            this._AddNode(RootData.Intance.Report_Finance_Comment, RootData.Intance.Report_Finance_Comment, ContentSelectionType2.FINANCES_COMMENT, this.m_oNode_Finances);            

            this._AddNode(RootData.Intance.Report_Marketing, RootData.Intance.Report_Marketing, ContentSelectionType2.MARKETING_INFO, this.m_oNode_Marketing);
            this._AddNode(RootData.Intance.Report_Marketing_Comment, RootData.Intance.Report_Marketing_Comment, ContentSelectionType2.MARKETING_COMMENT, this.m_oNode_Marketing);
            this.m_oSelectionTreeList.EndUnboundLoad();
        }

        protected ContentSelectionType2 _GetChecks()
        {
            ContentSelectionType2 nOTHING = ContentSelectionType2.NOTHING;
            nOTHING |= this._GetChecksSub(this.m_oStep123Node);
            nOTHING |= this._GetChecksSub(this.m_oStatusNode);
            nOTHING |= this._GetChecksSub(this.m_oActionsNode);
            nOTHING |= this._GetChecksSub(this.m_oBankNode);
            nOTHING |= this._GetChecksSub(this.m_oAppendixNodeEF);
            nOTHING |= this._GetChecksSub(this.m_oNode_Image);
            nOTHING |= this._GetChecksSub(this.m_oNode_Finances);
            nOTHING |= this._GetChecksSub(this.m_oNode_Marketing);
            return (nOTHING | this._GetChecksSub(this.m_oAppendixNodeQQS));
        }

        protected ContentSelectionType2 _GetChecksSub(TreeListNode oParentNode)
        {
            ContentSelectionType2 nOTHING = ContentSelectionType2.NOTHING;
            if (((oParentNode != null) && (oParentNode.Nodes != null)) && (oParentNode.Nodes.Count > 0))
            {
                foreach (TreeListNode node in oParentNode.Nodes)
                {
                    object obj2 = node["colID"];
                    if ((obj2 != null))
                    {
                        try
                        {
                            ContentSelectionType2 type2 = (ContentSelectionType2)obj2;
                            CheckState state = node.CheckState;
                            if (state == CheckState.Checked)
                            {
                                nOTHING |= type2;
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            return nOTHING;
        }

        protected void _SetChecks(ContentSelectionType2 eContents)
        {
            this._SetChecksSub(this.m_oStep123Node, eContents);
            this._SetChecksSub(this.m_oStatusNode, eContents);
            this._SetChecksSub(this.m_oActionsNode, eContents);
            this._SetChecksSub(this.m_oBankNode, eContents);
            this._SetChecksSub(this.m_oAppendixNodeEF, eContents);
            this._SetChecksSub(this.m_oAppendixNodeQQS, eContents);
            this._SetChecksSub(this.m_oNode_Image, eContents);
            this._SetChecksSub(this.m_oNode_Finances, eContents);
        }

        protected void _SetChecksSub(TreeListNode oParentNode, ContentSelectionType2 eContents)
        {
            if (((oParentNode != null) && (oParentNode.Nodes != null)) && (oParentNode.Nodes.Count > 0))
            {
                foreach (TreeListNode node in oParentNode.Nodes)
                {
                    object obj2 = node["colID"];
                    if (obj2 != null)
                    {
                        try
                        {
                            ContentSelectionType2 type = (ContentSelectionType2)obj2;
                            if ((eContents & type) != ContentSelectionType2.NOTHING)
                            {
                                node.StateImageIndex = 1;
                                node.CheckState = CheckState.Checked;
                            }
                            else
                            {
                                node.StateImageIndex = 0;
                                node.CheckState = CheckState.Unchecked;
                            }
                            //TreeListHelper.CheckParentsAndChilds(node);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }

        public WorkingStatusType CanFinish(ref string rsMessageText)
        {
            return WorkingStatusType.NO_STATUS;
        }
        private ProjectData m_oProject
        {
            get { return ProjectData.Intance; }
        }
        public bool CanProceed()
        {
            bool flag = true;
            if ((this.m_oProject != null) && (this.m_oProject.CurrentPeriod != null))
            {
                if (this.m_oVersionCombo.SelectedIndex == 0)
                {
                    this.m_oProject.CurrentPeriod.ContentsBTBKMU = this._GetChecks();
                    return flag;
                }
                if (this.m_oVersionCombo.SelectedIndex == 1)
                {
                    this.m_oProject.CurrentPeriod.ContentsBTBBank = this._GetChecks();
                    return flag;
                }
                if (this.m_oVersionCombo.SelectedIndex == 2)
                {
                    this.m_oProject.CurrentPeriod.ContentsBTBAll = this._GetChecks();
                }
            }
            return flag;
        }

        private ContentSelection GetContent()
        {
            ContentSelection selection = new ContentSelection();
            ContentSelectionType2 type = this._GetChecks();
            selection.BusinessModel = (type & ContentSelectionType2.STEP1_CONTENTS) != ContentSelectionType2.NOTHING;
            selection.BusinessModelCommentary = (type & ContentSelectionType2.STEP1_BANK_COMMENTS) != ContentSelectionType2.NOTHING;
            selection.BusinessField = (type & ContentSelectionType2.STEP2_CONTENTS) != ContentSelectionType2.NOTHING;
            selection.BusinessFieldCommentary = (type & (ContentSelectionType2.NOTHING | ContentSelectionType2.STEP2_BANK_COMMENTS)) != ContentSelectionType2.NOTHING;
            selection.BusinessPlan = (type & (ContentSelectionType2.NOTHING | ContentSelectionType2.STEP3_CONTENTS)) != ContentSelectionType2.NOTHING;
            selection.BusinessPlanCommentary = (type & (ContentSelectionType2.NOTHING | ContentSelectionType2.STEP3_BANK_COMMENTS)) != ContentSelectionType2.NOTHING;
            selection.StrategyFormulation = (((selection.BusinessModel || selection.BusinessModelCommentary) || (selection.BusinessField || selection.BusinessFieldCommentary)) || selection.BusinessPlan) || selection.BusinessPlanCommentary;
            selection.PotentialPortfolioChart = (type & (ContentSelectionType2.NOTHING | ContentSelectionType2.STATUS_POT_PORTFOLIO)) != ContentSelectionType2.NOTHING;
            selection.SuccessCommentary = (type & (ContentSelectionType2.NOTHING | ContentSelectionType2.STEP6_BANK_COMMENTS)) != ContentSelectionType2.NOTHING;
            selection.StatusQuoResultFactors = selection.PotentialPortfolioChart || selection.SuccessCommentary;
            selection.ActionList = (type & (ContentSelectionType2.NOTHING | ContentSelectionType2.ACTIONS_LIST)) != ContentSelectionType2.NOTHING;
            selection.ActionListCommentary = (type & ContentSelectionType2.STEP7_BANK_COMMENTS) != ContentSelectionType2.NOTHING;
            selection.Actions = selection.ActionList || selection.ActionListCommentary;
            selection.CommentaryOverView = (type & ContentSelectionType2.BANK_COMMENTS_OVERVIEW) != ContentSelectionType2.NOTHING;
            selection.FinishCommentary = (type & ContentSelectionType2.STEP8_BANK_COMMENTS) != ContentSelectionType2.NOTHING;
            selection.BankCommentaries = selection.CommentaryOverView || selection.FinishCommentary;
            selection.EFDefinition = (type & ContentSelectionType2.APP_FACTOR_DEFINITIONS) != ContentSelectionType2.NOTHING;
            selection.ImportanceChart = (type & ContentSelectionType2.APP_IMPORTANCE_DIAGRAM) != ContentSelectionType2.NOTHING;
            selection.ImportanceOverView = (type & ContentSelectionType2.APP_IMPORTANCE_TIMELINE) != ContentSelectionType2.NOTHING;
            selection.ImportanceStatement = (type & ContentSelectionType2.APP_JSTFNS_IMPORTANCE) != ContentSelectionType2.NOTHING;
            selection.ImportanceCommentary = (type & ContentSelectionType2.STEP4_BANK_COMMENTS) != ContentSelectionType2.NOTHING;
            selection.SuccessFactors = ((selection.EFDefinition || selection.ImportanceChart) || (selection.ImportanceOverView || selection.ImportanceStatement)) || selection.ImportanceCommentary;
            selection.QQSChart = (type & ContentSelectionType2.APP_QQS_BARCHARTS) != ContentSelectionType2.NOTHING;
            selection.QQSOverView = (type & ContentSelectionType2.APP_QQS_TIMELINE) != ContentSelectionType2.NOTHING;
            selection.QQSStatement = (type & ContentSelectionType2.APP_JSTFNS_QQS) != ContentSelectionType2.NOTHING;
            selection.QQSCommentary = (type & ContentSelectionType2.STEP5_BANK_COMMENTS) != ContentSelectionType2.NOTHING;
            selection.QQSAppraisal = ((selection.QQSChart || selection.QQSOverView) || selection.QQSStatement) || selection.QQSCommentary;
            selection.Appendix = selection.SuccessFactors || selection.QQSAppraisal;
            selection.Images = (type & ContentSelectionType2.IMAGE) != ContentSelectionType2.NOTHING;
            selection.Finances_Balances = (type & ContentSelectionType2.FINANCES_BALANCES) != ContentSelectionType2.NOTHING;
            selection.Finances_Investment = (type & ContentSelectionType2.FINANCES_INVESTMENT) != ContentSelectionType2.NOTHING;
            selection.Finances_Prices = (type & ContentSelectionType2.FINANCES_PRICE) != ContentSelectionType2.NOTHING;
            selection.Finances_Trades = (type & ContentSelectionType2.FINANCES_TRADE) != ContentSelectionType2.NOTHING;
            selection.Finances_InvestmentPlan = (type & ContentSelectionType2.FINANCES_INVESTMENTPLAN) != ContentSelectionType2.NOTHING;
            selection.Finances_Liquidity = (type & ContentSelectionType2.FINANCES_LIQUIDITY) != ContentSelectionType2.NOTHING;
            selection.Finances_Profit = (type & ContentSelectionType2.FINANCES_PROFIT) != ContentSelectionType2.NOTHING;
            selection.Finances_Comment = (type & ContentSelectionType2.FINANCES_COMMENT) != ContentSelectionType2.NOTHING;
            selection.Finances_Sheet_Statement = (type & ContentSelectionType2.FINANCES_Sheet_Statement) != ContentSelectionType2.NOTHING;
            selection.Marketing = (type & ContentSelectionType2.MARKETING) != ContentSelectionType2.NOTHING;
            selection.Marketing_Comment = (type & ContentSelectionType2.MARKETING_COMMENT) != ContentSelectionType2.NOTHING;
            return selection;
        }

        private void OnBtnCreateClick(object sender, EventArgs e)
        {
            //if (VMConfig.Intance.Constants.ReportsEnabled)
            {
                string rsErr = string.Empty;
                if (!this.ShowReport(ref rsErr))
                {
                    //MBH.Error(rsErr);
                }
            }
        }

        private void OnContentVersionChanged(object sender, EventArgs e)
        {
            this.ShowData();
        }

        private void OnContentVersionChanging(object sender, ChangingEventArgs e)
        {
            this.CanProceed();
        }

        private void OnTreeListMouseDown(object sender, MouseEventArgs e)
        {
            //if (e.Button == MouseButtons.Left)
            //{
            //    TreeListHitInfo info = this.m_oSelectionTreeList.CalcHitInfo(new Point(e.X, e.Y));
            //    if ((info.HitInfoType == HitInfoType.StateImage) || (info.HitInfoType == HitInfoType.Cell))
            //    {
            //        this._ChangeCheckState(info.Node);
            //    }
            //}
        }

        public void Rollback()
        {
            this.ShowData();
        }

        public bool RollbackPossible()
        {
            return true;
        }

        public int ShowData()
        {
            int num = 0;
            if ((this.m_oProject == null) || (this.m_oProject.CurrentPeriod == null))
            {
                this._SetChecks(ContentSelectionType2.NOTHING);
                this.m_oVersionCombo.Enabled = false;
                this.m_oSelectionTreeList.Enabled = false;
                this.m_oCreateButton.Enabled = false;
                this.m_oStep123Node.Expanded = false;
                this.m_oStatusNode.Expanded = false;
                this.m_oBankNode.Expanded = false;
                this.m_oActionsNode.Expanded = false;
                this.m_oAppendixNode.Expanded = false;
                return num;
            }
            this.m_oVersionCombo.Enabled = true;
            this.m_oSelectionTreeList.Enabled = true;
            this.m_oCreateButton.Enabled = true;
            this.m_oStep123Node.Expanded = true;
            this.m_oStatusNode.Expanded = true;
            this.m_oBankNode.Expanded = true;
            this.m_oActionsNode.Expanded = true;
            this.m_oAppendixNode.Expanded = true;
            this.m_oSelectionTreeList.BeginUpdate();
            switch (this.m_oVersionCombo.SelectedIndex)
            {
                case 0:
                    this._SetChecks(this.m_oProject.CurrentPeriod.ContentsBTBKMU);
                    break;

                case 1:
                    this._SetChecks(this.m_oProject.CurrentPeriod.ContentsBTBBank);
                    break;

                case 2:
                    this._SetChecks(this.m_oProject.CurrentPeriod.ContentsBTBAll);
                    break;
            }
            this.m_oSelectionTreeList.EndUpdate();
            return num;
        }

        private bool ShowReport(ref string rsErr)
        {
            bool flag = true;
            StringCollection aHiddenElements = new StringCollection();
            try
            {
                //todo
                ContentSelection content = this.GetContent();
                //if (((!content.StrategyFormulation && !content.StatusQuoResultFactors) && (!content.Actions && !content.BankCommentaries)) && !content.Appendix)
                //{
                //    flag = false;
                //    rsErr = "Es wurden keine Inhalte zum Anzeigen ausgew\x00e4hlt.";
                //    return flag;
                //}
                if (this.m_oContentsReport != null)
                {
                    this.m_oContentsReport.ClosePreview();
                    this.m_oContentsReport.Dispose();
                    this.m_oContentsReport = null;
                }
                this.m_oContentsReport = new XtraReport2();
                this.m_oContentsReport.Title = string.Empty;// " Intangible Assets";
                flag = this.m_oContentsReport.CreateReport(content, aHiddenElements, ref rsErr);
                if (flag)
                {
                    ReportTemplate.GetMessageString(aHiddenElements);
                    ReportTemplate.ShowReportPreview(this.m_oContentsReport);
                }
            }
            catch (Exception exception)
            {
                flag = false;
                rsErr = "Fehler in DVContents.ShowReport: " + exception.Message;
                Log.LogException(exception);
            }
            return flag;
        }

        public TabIDType2 ID
        {
            get
            {
                return this.m_eType;
            }
        }

        private void m_oSelectionTreeList_AfterCheckNode(object sender, NodeEventArgs e)
        {
            SetCheckedChildNodes(e.Node, e.Node.CheckState);
            SetCheckedParentNodes(e.Node, e.Node.CheckState);
        }

        private void m_oSelectionTreeList_BeforeCheckNode(object sender, CheckNodeEventArgs e)
        {
            e.State = (e.PrevState == CheckState.Checked ? CheckState.Unchecked : CheckState.Checked);
        }

        void SetCheckedChildNodes(TreeListNode node, CheckState check)
        {
            for (int i = 0; i < node.Nodes.Count; i++)
            {
                node.Nodes[i].CheckState = check;
                node.CheckState = check;
                SetCheckedChildNodes(node.Nodes[i], check);
            }
        }
        void SetCheckedParentNodes(TreeListNode node, CheckState check)
        {
            if (node.ParentNode != null)
            {
                bool b = false;
                CheckState state;
                for (int i = 0; i < node.ParentNode.Nodes.Count; i++)
                {
                    state = (CheckState)node.ParentNode.Nodes[i].CheckState;
                    if (!check.Equals(state))
                    {
                        b = !b;
                        break;
                    }
                }
                node.ParentNode.CheckState = b ? CheckState.Indeterminate : check;
                SetCheckedParentNodes(node.ParentNode, check);
            }
        }
    }
    [Flags]
    public enum ContentSelectionType2 : ulong
    {
        ACTIONS_LIST = 0x10000L,
        APP_FACTOR_DEFINITIONS = 0x100000000L,
        APP_IMPORTANCE_DIAGRAM = 0x200000000L,
        APP_IMPORTANCE_TIMELINE = 0x400000000L,
        APP_JSTFNS_IMPORTANCE = 0x800000000L,
        APP_JSTFNS_QQS = 0x40000000000L,
        APP_QQS_BARCHARTS = 0x10000000000L,
        APP_QQS_TIMELINE = 0x20000000000L,
        BANK_COMMENTS_OVERVIEW = 0x1000000L,
        NOTHING = 0L,
        STATUS_POT_PORTFOLIO = 0x200L,
        STEP1_BANK_COMMENTS = 2L,
        STEP1_CONTENTS = 1L,
        STEP2_BANK_COMMENTS = 0x10L,
        STEP2_CONTENTS = 8L,
        STEP3_BANK_COMMENTS = 0x80L,
        STEP3_CONTENTS = 0x40L,
        STEP4_BANK_COMMENTS = 0x1000000000L,
        STEP5_BANK_COMMENTS = 0x80000000000L,
        STEP6_BANK_COMMENTS = 0x400L,
        STEP7_BANK_COMMENTS = 0x20000L,
        STEP8_BANK_COMMENTS = 0x2000000L,
        IMAGE = 0x8000000000000,//b1000000000000000000000000000000000000000000000000000
        FINANCES = 0x7F00000000000,//b111111100000000000000000000000000000000000000000000,
        FINANCES_BALANCES = 0x100000000000,//b000000100000000000000000000000000000000000000000000,
        FINANCES_INVESTMENT = 0x200000000000,//b000001000000000000000000000000000000000000000000000,
        FINANCES_PRICE = 0x400000000000,//b000010000000000000000000000000000000000000000000000,
        FINANCES_TRADE = 0x800000000000,//b000100000000000000000000000000000000000000000000000,
        FINANCES_INVESTMENTPLAN = 0x1000000000000,//b001000000000000000000000000000000000000000000000000,
        FINANCES_LIQUIDITY = 0x20000000000000,//b010000000000000000000000000000000000000000000000000,
        FINANCES_PROFIT = 0x400000000000000,//b100000000000000000000000000000000000000000000000000
#warning can check lai
        FINANCES_Sheet_Statement = 0x800000000000000,//b100000000000000000000000000000000000000000000000000
        FINANCES_COMMENT = 0x800000000000000,//b100000000000000000000000000000000000000000000000000
        MARKETING = 0x3000000000000000,//b111111100000000000000000000000000000000000000000000,
        MARKETING_INFO = 0x1000000000000000,//b000000100000000000000000000000000000000000000000000,
        MARKETING_COMMENT = 0x2000000000000000,//b000001000000000000000000000000000000000000000000000,
       
    }
    [Flags]
    public enum TabIDType2 : ulong
    {
        UNKNOWN = 0,
        STEP1_PART1 = 1,
        STEP1_PART2 = 2,
        STEP2_PART1 = 256,
        STEP2_PART2 = 512,
        STEP3_PART1 = 65536,
        STEP3_PART2 = 131072,
        ICDEF_HK = 1048576,
        ICDEF_SK = 2097152,
        ICDEF_BK = 4194304,
        ICDEF_ALL = 8388608,
        QQS_LIST = 16777216,
        ANA_POTENTIALPORTF = 268435456,
        ANA_IMPORTANCE = 536870912,
        ANA_QQS_BARS = 1073741824,
        ACN_LIST = 1099511627776,
        CREA_BANK = 17592186044416,
        CREA_CONTENTS = 35184372088832

    }
    public enum WorkingStatusType
    {
        OPEN = 0,
        FINISHED = 1,
        NO_STATUS = 2,
    }
    public class ToolTipps
    {
        private static int m_iTooltipDuration = -2147483648;
        private static int m_iToolTipInitialDelay = -2147483648;

        public static ToolTipController getController()
        {
            if (m_iTooltipDuration == -2147483648)
            {
                m_iTooltipDuration = 100; //todo Config.UI.ToolTipDuration;
            }
            if (m_iToolTipInitialDelay == -2147483648)
            {
                m_iToolTipInitialDelay = 200;// todo Config.UI.ToolTipInitialDelay;
            }
            ToolTipController controller = new ToolTipController();
            if (m_iTooltipDuration == 0)
            {
                controller.Active = false;
                return controller;
            }
            controller.Active = true;
            controller.AutoPopDelay = m_iTooltipDuration;
            controller.InitialDelay = m_iToolTipInitialDelay;
            return controller;
        }
    }
    public class WBTB_Button : SimpleButton
    {
        private Container components;

        public WBTB_Button()
        {
            this.InitializeComponent();
            base.ToolTipController = ToolTipps.getController();
            this.Appearance.BorderColor = Color.FromArgb(0x33, 0x33, 0x33); //Color.FromArgb(160, 0x7e, 0x7e);
            this.Appearance.Options.UseBorderColor = true;
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.components = new Container();
        }
    }
    public class TreeListHelper
    {
        protected static void _CheckChilds(TreeListNode oNode, CheckState iCheck)
        {
            if ((oNode != null) && oNode.HasChildren)
            {
                foreach (TreeListNode node in oNode.Nodes)
                {
                    node.CheckState = iCheck;
                    node.StateImageIndex = (iCheck == CheckState.Checked) ? 1 : 0;
                    _CheckChilds(node, iCheck);
                }
            }
        }

        protected static void _CheckParents(TreeListNode oNode)
        {
            if (oNode.ParentNode != null)
            {
                bool flag = false;
                bool flag2 = false;
                CheckState @unchecked = CheckState.Unchecked;
                foreach (TreeListNode node in oNode.ParentNode.Nodes)
                {
                    @unchecked = node.CheckState;
                    if (@unchecked == CheckState.Unchecked)
                    {
                        flag = true;
                        if (!flag2)
                        {
                            continue;
                        }
                    }
                    else if (@unchecked == CheckState.Checked)
                    {
                        flag2 = true;
                        if (!flag)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        flag = true;
                        flag2 = true;
                    }
                    break;
                }
                CheckState indeterminate = CheckState.Checked;
                if (flag)
                {
                    if (flag2)
                    {
                        indeterminate = CheckState.Indeterminate;
                    }
                    else
                    {
                        indeterminate = CheckState.Unchecked;
                    }
                }
                oNode.CheckState = indeterminate;
                switch (indeterminate)
                {
                    case CheckState.Unchecked:
                        oNode.ParentNode.StateImageIndex = 0;
                        break;

                    case CheckState.Checked:
                        oNode.ParentNode.StateImageIndex = 1;
                        break;

                    case CheckState.Indeterminate:
                        oNode.ParentNode.StateImageIndex = 2;
                        break;
                }
                _CheckParents(oNode.ParentNode);
            }
        }

        public static void CheckParentsAndChilds(TreeListNode oNode)
        {
            if (oNode != null)
            {
                //object obj2 = oNode.GetValue("colCheck");
                //if (obj2 != null)
                {
                    TreeList treeList = oNode.TreeList;
                    CheckState iCheck = oNode.CheckState;
                    if ((iCheck != CheckState.Indeterminate) && (treeList != null))
                    {
                        treeList.BeginUpdate();
                        _CheckChilds(oNode, iCheck);
                        _CheckParents(oNode);
                        treeList.EndUpdate();
                    }
                }
            }
        }




    }
}
